package chartPostProcessors;

import java.awt.Shape;
import java.io.Serializable;
import java.util.Map;

import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.LineAndShapeRenderer;

import de.laures.cewolf.ChartPostProcessor;

public class RangePostProcessor implements ChartPostProcessor, Serializable {
	
	private int[] minMax;
	
	@Override
	public void processChart(Object arg0, Map arg1) {
		JFreeChart chart = (JFreeChart)arg0;
		CategoryPlot plot = (CategoryPlot) chart.getPlot();
		NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
		rangeAxis.setRange((minMax[0]-100)/100d,(minMax[1]+100)/100d);
		if(plot.getRenderer() instanceof LineAndShapeRenderer){
			((LineAndShapeRenderer)plot.getRenderer()).setBaseShapesVisible(true);
		}

	}
	public void setMinMax(int[] minMax) {
		this.minMax = minMax;
	}
	public int[] getMinMax() {
		return minMax;
	}
}
